package com.ruoyi.web.controller.myController;

import com.ruoyi.system.domain.vo.Results;
import com.ruoyi.system.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api")
public class loginCountController {
    @Autowired
    private RedisService redisService;
//    public Results getLoginCount(HttpSessionEvent se){
//        Map<String, List<HttpSession>> map =(Map<String, List<HttpSession>>) se.getSession().getAttribute("map");
//    }
    @GetMapping("/getLoginCount")
    public Results getLoginCount(){
        Integer loginCount =(Integer) redisService.get("LoginCount");
        if(loginCount==null){
            return new Results(500,"服务器内部错误",null);
        }
        return new Results(200,"ok",loginCount);
    }
    @GetMapping("/getTotalLoginCount")
    public Results getTotalLoginCount(){
        Integer loginCount =(Integer) redisService.get("LoginTotalCount");
        if(loginCount==null){
            return new Results(500,"服务器内部错误",null);
        }
        return new Results(200,"ok",loginCount);
    }
}
